package service

import (
	"gitee.com/wendyRose/payment/domain/model"
	"gitee.com/wendyRose/payment/domain/repository"
)

type IPaymentDataService interface {
	AddPayment(payment *model.Payment) (int64, error)
	UpdatePayment(payment *model.Payment) error
	DeletePaymentByID(paymentID int64) error
	FindPaymentByID(paymentID int64) (*model.Payment, error)
	FindAllPayment() ([]model.Payment, error)
}

type PaymentDataService struct {
	PaymentRepository repository.IPaymentRepository
}

func NewPaymentDataService(paymentRepository repository.IPaymentRepository) IPaymentDataService {
	return &PaymentDataService{PaymentRepository: paymentRepository}
}

func (p *PaymentDataService) AddPayment(payment *model.Payment) (int64, error) {
	return p.PaymentRepository.AddPayment(payment)
}

func (p *PaymentDataService) UpdatePayment(payment *model.Payment) error {
	return p.PaymentRepository.UpdatePayment(payment)
}

func (p *PaymentDataService) DeletePaymentByID(paymentID int64) error {
	return p.PaymentRepository.DeletePaymentByID(paymentID)
}

func (p *PaymentDataService) FindPaymentByID(paymentID int64) (*model.Payment, error) {
	return p.PaymentRepository.FindPaymentByID(paymentID)
}

func (p *PaymentDataService) FindAllPayment() ([]model.Payment, error) {
	return p.PaymentRepository.FindAllPayment()
}
